﻿@model TanWeb.Models.Entities.Products
@{
    ViewBag.Title = "Danh sách sản phẩm";
    Layout = "~/Views/Shared/_Master.cshtml";
    System.Collections.IList listGroup = (System.Collections.IList)TanWeb.Helpers.Utils.GetSession(TanWeb.Helpers.Constants.SS_LISTMENUITEM);
    System.Collections.IList listSubGroup = (System.Collections.IList)TanWeb.Helpers.Utils.GetSession(TanWeb.Helpers.Constants.SS_LISTSUBMENUITEM);
}

<script src="@Url.Content("~/Scripts/Common/script.js")" type="text/javascript"></script>
@Scripts.Render("~/Scripts/Pages/main.js")
@Scripts.Render("~/Scripts/Common/modalPopup.js")

<div class="masterPage">
    <div class="box_center">
        <div class="div_action">
            <input type="button" id="btnAddNew" class="button disabled width-100" value="Thêm" disabled="disabled" />
            <input type="button" id="btnDelete" class="button disabled width-100" value="Xóa" disabled="disabled" />
            <input type="button" id="btnAddGroup" class="button width-100" value="Thêm nhóm" />
        </div>
    </div>
    <div class="box_center">
        <span>Nhóm cha</span>
        <select id="cboGroup" name="groupId" @(listGroup.Count == 0 ? "class=\"disabled\" disabled=\"disabled\"" : "")>
            <option value="0">Chọn nhóm cha</option>
            @foreach (TanWeb.Models.Entities.ItemGroup item in listGroup)
            {
                <option value="@item.id">@item.GroupName</option>
            }
        </select>
        <span>Nhóm con</span>
        <select id="cboSubGroup" name="subGroupId">
            <option value="0" class="disabled" disabled="disabled">Chọn nhóm con</option>
            @foreach (TanWeb.Models.Entities.SubItemGroup item in listSubGroup)
            {
                <option value="@item.id">@item.SubGroupName</option>
            }
        </select>
    </div>
    <div class="box_center info">
        <table>
            <thead>
                <tr>
                    <th class="width-20">&nbsp;</th>
                    <th class="width-100">Hình ảnh</th>
                    <th class="width-150">Tên sản phẩm</th>
                    <th class="width-150">Giá</th>
                    <th class="width-200">Mô tả</th>
                    <th class="width-55">&nbsp;</th>
                    <th class="width-55">&nbsp;</th>
                </tr>
            </thead>
            <tbody>
                @{ if (Model.ProductProfile.Count == 0)
                   {
                        <tr><td colspan="6">@TanWeb.Helpers.Constants.GRID_EMPTY_WARNING</td></tr>
                   }
                   else
                   {
                       string updateLink = "/Master/Update?";
                       foreach (TanWeb.Models.Entities.ProductProfile item in Model.ProductProfile)
                       {
                           var chkDelId = "chkDelProduct" + item.id;
                           string link = updateLink + "groupId=" + item.GroupId + "&subGroupId=" +
                               item.SubGroupId + "&productId=" + item.id;
                           <tr>
                               <td class="width-20"><input type="checkbox" name="chkDelProducts" id="@chkDelId" class="checkbox" /></td>
                               <td class="width-100"><a href="#"><img src="@item.GetTempImagePath()" class="image" alt="" productId="@item.id" groupId="@item.GroupId" subGroupId="@item.SubGroupId" /></a></td>
                               <td class="width-150">
                                    <a href="@link" class="link">@item.Name</a>
                               </td>
                               <td class="width-150">@string.Format(@item.Price > 0 ? "{0:#,###} VNĐ" : TanWeb.Helpers.Constants.PRICE_NOT_SET, @item.Price)</td>
                               <td class="width-200">@item.Description</td>
                               <td class="width-55"><a>Sửa</a></td>
                               <td class="width-55"><a>Xóa</a></td>
                           </tr>     
                       }
                   }
                }
            </tbody>
        </table>
    </div>
</div>
<input id="totalPage" type="hidden" value="@Model.PageCount" />
<input id="pageIndex" type="hidden" value="@Model.CurrentPage" />
<input id="groupId" type="hidden" value="@ViewBag.GroupId" />
<input id="subGroupId" type="hidden" value="@ViewBag.SubGroupId" />
<p class="pagination"></p>
<div class="box_bottom"></div>
